import axios from 'axios'
const baseURL= process.env.NODE_ENV ==='development'? 'http://localhost:3000':'真实接口'
const service =axios.create({
  baseURL,
  timeout:3000
})
service.interceptors.request.use(config=>{
  config.headers={
    'x-token':'hjbgjfkdklg'
  }
  return config
})
service.interceptors.response.use(config=>{
  if(config.status >=200 && config.status <=300){
    const res = config.data 
    if(res.code===200){
      return res.data
    }
    return Promise.reject(res)
  }
  return Promise.reject(config)
})
export default service